<?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    return view('welcome');
});

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/

Route::group(['middleware' => ['web']], function () {
    // Route::auth();
    // Authentication Routes...
    Route::get('login',                        'Auth\AuthController@showLoginForm');
    Route::post('login',                       'Auth\AuthController@login');
    Route::get('logout',                       'Auth\AuthController@logout');

    // Registration Routes...
    // Route::get('register',                  'Auth\AuthController@showRegistrationForm');
    // Route::post('register',                 'Auth\AuthController@register');

    // Password Reset Routes...
    Route::get('password/reset/{token?}',      'Auth\PasswordController@showResetForm');
    Route::post('password/email',              'Auth\PasswordController@sendResetLinkEmail');
    Route::post('password/reset',              'Auth\PasswordController@reset');

    Route::get('home',                         'HomeController@index');
    Route::get('article',                      'ArticleController@index');
    Route::get('article/{slug}',               'ArticleController@show');

    Route::get('farm',                         'FarmController@index');
    Route::get('farm_categories',              'FarmCategoryController@index');
    Route::get('farm_products',                'FarmProductController@index');
    Route::get('farm_products/{id}',           'FarmProductController@show');
    Route::post('farm_combinations',           'FarmCombinationController@store');

    Route::get('bookmark',                     'BookmarkController@index');
    Route::get('fund',                         'BookmarkController@fund');
    Route::get('fund/list',                    'BookmarkController@getList');
    Route::get('script',                       'BookmarkController@script');
    Route::get('update_comb',                  'BookmarkController@update_comb');
    
    // 监控的页面和异步请求
    Route::get('jk',                           'BookmarkController@jk');
    Route::get('sync',                         'BookmarkController@sync');
});

Route::group(['namespace' => 'Admin', 'middleware' => ['web', 'auth']], function () {
    Route::get('admin',                        'HomeController@index');
    Route::get('admin/data',                   ['as' => 'admin.data', 'uses' => 'HomeController@data']);
    
    Route::get('users/dashboard',              'UserController@dashboard');
    Route::get('admin/users',                  'UserController@index');
    Route::post('admin/users',                 'UserController@store');
    Route::delete('admin/users/{id}',          'UserController@destroy');
    Route::put('admin/users/{id}',             'UserController@update');

    Route::get('permissions/dashboard',        'PermissionController@dashboard');
    Route::get('admin/permissions',            'PermissionController@index');
    Route::post('admin/permissions',           'PermissionController@store');
    Route::delete('admin/permissions/{id}',    'PermissionController@destroy');
    Route::put('admin/permissions/{id}',       'PermissionController@update');

    Route::get('roles/dashboard',              'RoleController@dashboard');
    Route::get('admin/roles',                  'RoleController@index');
    Route::post('admin/roles',                 'RoleController@store');
    Route::delete('admin/roles/{id}',          'RoleController@destroy');
    Route::put('admin/roles/{id}',             'RoleController@update');
    
    Route::get('admin/upload',                 'UploadController@index');
    Route::post('admin/upload/file',           'UploadController@uploadFile');
    Route::delete('admin/upload/file',         'UploadController@deleteFile');
    Route::post('admin/upload/folder',         'UploadController@createFolder');
    Route::delete('admin/upload/folder',       'UploadController@deleteFolder');
});